<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>接口列表</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/sweetalert.css"/>
</head>
<body>
<div class="container" style="margin-top: 5px">
    <h3 style="font-weight: bold;">服务名：<span class="label label-success"
                                             th:text="${serviceName}">demoService-provider</span></h3>
    <h4 style="font-weight: bold;color: #797979">地址：<span class="label label-info"
                                                          th:text="${address}">127.0.0.1:20880</span></h4>
    <h4 style="font-weight: bold;color: #797979">协议：<span class="label label-info" th:text="${protocol}">dubbo</span>
    </h4>
    <div class="row">
        <div class="col-sm-10">
            <div class="input-group">
                <span class="input-group-addon" id="basic-addon1">描述</span>
                <input type="text" class="form-control" aria-describedby="basic-addon1" id="desc"
                       style="font-weight: bold" th:value="${serviceDesc}">
                <input type="hidden" id="serviceId" th:value="${serviceId}">
            </div>
        </div>
        <div class="col-sm-2">
            <button class="btn" id="updateDesc" type="button">
                提交修改
            </button>
        </div>

    </div>
    <br/>
    <div class="list-group">
        <h4 style="font-weight: bold">接口列表：</h4>
        <a class="list-group-item" th:each="iface,ifaceStat:${interfaces}"
           th:href="@{'/page/method/list?cServiceId='+${iface.getCServiceId()}+'&cName='+${iface.getCName()}}" target="_blank">
            <h4 class="list-group-item-heading" th:text="${iface.getCName()}"></h4>
            <br/>
        </a>
    </div>
</div>
</body>
<script type="text/javascript" src="/js/sweetalert.min.js"></script>
<script>
    $("#updateDesc").bind("click", function () {
        const serviceId = $("#serviceId").val();
        const desc = $("#desc").val();
        const data = {
            cId: serviceId,
            cDesc: desc
        };
        $.ajax({
            url: '/base/service/desc',
            type: 'PUT',
            dataType: 'json',
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function (data) {
                console.log(data);
                if (data.flag) {
                    swal("操作成功!", "已成功修改！", "success");
                } else {
                    swal("更新失败!请稍后重试");
                }
            }
        })
    })
</script>
</html>